package com.baosight.risk.web.jlta;

import com.baosight.risk.api.jlta.JltaNoticeService;
import com.baosight.risk.base.controller.BaseController;
import com.baosight.risk.common.result.AjaxResult;
import com.baosight.risk.service.jlta.entity.JltaNotice;
import com.baosight.risk.service.jlta.vo.JltaNoticeVO;
import com.baosight.risk.service.jlta.vo.MutiTeamVO;
import com.baosight.risk.service.xtzy.entity.XtzyUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.core.MediaType;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 作者： lishaoqing
 * 时间： 2019年07月09日
 * 描述： JltaNoticeController
 * 版本: v1.0
 */
@Api(value = "团队公告", description = "团队公告", produces = MediaType.APPLICATION_JSON)
@Slf4j
@RestController
@RequestMapping("/jlta/notice")
public class JltaNoticeController extends BaseController {

    @Autowired
    private JltaNoticeService jltaNoticeService;

    @ApiOperation("获取公告列表")
    @GetMapping("noticeList")
    public AjaxResult noticeList(JltaNotice jltaNotice) {
        startPage();
        return getResultPage(jltaNoticeService.selectNoticeList(jltaNotice));
    }

    @ApiOperation("新增公告")
    @PostMapping("addNotice")
    public AjaxResult addNotice(@RequestBody MutiTeamVO vo) {
        Integer result = jltaNoticeService.addNotice(vo);
        if (result == 0) {
            return AjaxResult.error();
        }
        return AjaxResult.success();
    }

    @ApiOperation("删除公告")
    @PutMapping("deleteNotice")
    public AjaxResult deleteNotice(@RequestBody MutiTeamVO mutiTeamVO) {

        Integer integer = jltaNoticeService.deleteNotice(mutiTeamVO);
        if (integer == 0) {
            return error("没有权限删除！");
        }
        return AjaxResult.success();
    }

    @ApiOperation("修改公告")
    @PostMapping("editNotice")
    public AjaxResult editNotice(@RequestBody MutiTeamVO teamVO) {
        Integer integer = jltaNoticeService.editNotice(teamVO);
        if (integer > 0) {
            return AjaxResult.success();
        }
        return AjaxResult.error("没有权限修改！");
    }

    @ApiOperation("发布公告")
    @PutMapping("releaseNotice")
    public AjaxResult releaseNotice(@RequestBody List<String> ids) {
        jltaNoticeService.releaseNotice(ids);
        return AjaxResult.success();
    }


}
